package com.schoolcloud.social.controller.forum;

import com.schoolcloud.common.model.PageDTO;
import com.schoolcloud.common.model.R;
import com.schoolcloud.social.entity.SocBard;
import com.schoolcloud.social.query.BardQuery;
import com.schoolcloud.social.query.UserForumQuery;
import com.schoolcloud.social.service.PostInteractionService;
import com.schoolcloud.social.service.SocBardService;
import com.schoolcloud.social.vo.ForumUserVO;
import com.schoolcloud.social.vo.SocBardVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/social/bard")
@RequiredArgsConstructor
public class SocBardController {
    private final SocBardService socBardService;
    private final PostInteractionService postInteractionService;

    /**创建贴吧
     * @param socBard
     * @return {@link R }
     */
    @PostMapping
    public R createBard(@RequestBody SocBard socBard) {
        socBardService.createBard(socBard);
        return R.ok();
    }

    /**获取贴吧列表
     * @param query
     * @return {@link R }<{@link PageDTO }<{@link SocBard }>>
     */
    @GetMapping("/page")
    public R<PageDTO<SocBard>> getBardPage(BardQuery query) {
        PageDTO<SocBard> page = socBardService.getBardPage(query);
        return R.ok(page);
    }
    @GetMapping("/vo/page")
    public R<PageDTO<SocBardVO>> getBardVoPage(BardQuery query) {
        PageDTO<SocBardVO> page = postInteractionService.getBardVoPage(query);
        return R.ok(page);
    }

    /**
     * 获取bard详细信息
     *
     * @param bardId
     * @return {@link R }<{@link SocBardVO }>
     */
    @GetMapping("/{bardId}")
    public R<SocBardVO> getBardById(@PathVariable String bardId) {
        SocBardVO socBard = postInteractionService.getBardInfoById(bardId);
        return R.ok(socBard);
    }

    @GetMapping("/by/postId/{postId}")
    public R<SocBardVO> getBardByPostId(@PathVariable String postId) {
        SocBardVO socBard = postInteractionService.getBardInfoByPostId(postId);
        return R.ok(socBard);
    }
    @GetMapping("/user/follow/list/{userId}")
    public R<List<SocBardVO>> getFollowBardByUserId(@PathVariable String userId) {
        List<SocBardVO> socBard = postInteractionService.getFollowBardByUserId(userId);
        return R.ok(socBard);
    }
}
